import { InjectionKey} from 'vue'
import { createStore,Store,useStore as baseUseStore } from 'vuex';
import app,{IAppState} from '@/store/modules/app';
import tagsView, { ITagsViewState } from '@/store/modules/tagsView'
import getters from './getters';
import createPersistedState from 'vuex-persistedstate'
export interface IRootState{
    app:IAppState;
    tagsView: ITagsViewState;
}
export const key:InjectionKey<Store<IRootState>>=Symbol();
const persisteAppState = createPersistedState({
    storage:window.sessionStorage,
    key:'vuex_app',
    paths:['app.sidebar.opened','app.size']
})
export default createStore<IRootState>({
    plugins:[
        persisteAppState
    ],
    getters,
    modules:{
        app,
        tagsView
    }
})
export function useStore(){
    return baseUseStore(key)
}